package com.sz.common.base.constants;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * Function: UnitSetting <br>
 * Author: Charles <br>
 * Date: 2016-12-28 10:27:00
 */
public class UnitSetting {
    /**
     * 仅用于单元测试，请勿引用此变量
     */
    static final String UNIT_TEST_FLAG_RANDOM = UUID.randomUUID().toString().replaceAll("-", "");


    /**
     * 仅用于单元测试，请勿引用此方法
     */
    public static String getUnitTestFlag() {
        return "com.sz.unit.test.flag." + UNIT_TEST_FLAG_RANDOM;
    }

    /**
     * @return
     */
    public static boolean isUnitTest() {
        return "true".equals(System.getProperty(getUnitTestFlag()));
    }


    private static Map<String, Object> mockObjects = new HashMap<>();

    /**
     * @param key
     * @return
     */
    public static Object getMockObject(String key) {
        return mockObjects.get(key);
    }

    public static void setMockObject(String key, Object obj) {
        mockObjects.put(key, obj);
    }
}
